home *** CD-ROM | disk | FTP | other *** search
/ World of Video / World of Video.iso / gfxprograms / 3dprograms / t3dlib / source / tddd2vort.c < prev    next >
C/C++ Source or Header  |  1995-02-13  |  1KB  |  61 lines

  1. /* tddd2vort.c - convert TTDDD file to Vort input file
  2.  *             - written by Glenn M. Lewis - 10/11/91
  3.  */
  4.  
  5. static char rcs_id[] = "$Id: tddd2vort.c,v 1.6 1993/02/14 17:44:16 glewis Exp $";
  6.  
  7. #include <stdio.h>
  8. #include "t3dlib.h"
  9. #ifdef __STDC__
  10. #include <stdlib.h>
  11. #include <strings.h>
  12. #include "tddd2vort_protos.h"
  13. #endif
  14.  
  15. main(argc, argv)
  16. int argc;
  17. char *argv[];
  18. {
  19.     char filename[256], rootname[256], *c1, *c2;
  20.     int i;
  21.     WORLD *world;
  22.     FILE *inp, *out;
  23.  
  24.     rootname[0] = filename[0] = '\0';
  25. /*    strcpy(rootname, "model");    ** The default for reading stdin */
  26.     for (i=1; i<argc; i++) {
  27.         if (argv[i][0] == '-') {
  28.             switch(argv[i][1]) {
  29.                 case 'h':
  30.                 default:
  31.                     fprintf(stderr, "Usage: %s [infile] [outfile]\n", argv[0]);
  32.                     exit(-1);
  33.             }
  34.         } else if (filename[0]) {
  35.             strcpy(rootname, argv[i]);
  36.         } else {
  37.             strcpy(filename, argv[i]);    /* Make root of filename the default */
  38.             for (c1=rootname,c2=argv[i]; (*c1 = *c2++) && *c1!='.'; c1++) ;
  39.             *c1 = '\0';
  40.             strcat(rootname, ".vort");
  41.         }
  42.     }
  43.  
  44.     if (!filename[0]) inp = stdin;
  45.     else if (!(inp = fopen(filename, "r"))) {
  46.         fprintf(stderr, "Can't open '%s' for input.\n", filename);
  47.         exit(-1);
  48.     }
  49.     if (!rootname[0]) out = stdout;
  50.     else if (!(out = fopen(rootname, "w"))) {
  51.         fprintf(stderr, "Can't open '%s' for output.\n", rootname);
  52.         exit(-1);
  53.     }
  54.  
  55.     world = read_World(inp);
  56.     write_Vort(world, out);
  57.     free_World(world);
  58.     exit(0);
  59. }
  60.  
  61.